
package com.yuan.unit;

import android.annotation.SuppressLint;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 时间工具类
 * 
 * @author YUAN
 */
public class TimeUtils {

    @SuppressLint("SimpleDateFormat")
    public static String getNowTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    public static int getMonthLastDay(int year, int month)
    {
        Calendar a = Calendar.getInstance();
        a.set(Calendar.YEAR, year);
        a.set(Calendar.MONTH, month - 1);
        a.set(Calendar.DATE, 1);// 把日期设置为当月第一天
        a.roll(Calendar.DATE, -1);// 日期回滚一天，也就是最后一天
        int maxDate = a.get(Calendar.DATE);
        return maxDate;
    }
    // @SuppressLint("SimpleDateFormat")
    // public static String getNowTimeHourMinute() {
    // SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
    // Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
    // String str = formatter.format(curDate);
    // return str;
    // }
}
